package com.xiaohudie.SGGio;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author xiao hu die
 * @Date 2022/3/23 23:10
 * @Version 1.0
 */
public class FileIntputtest {
    public static void main(String[] args) {
 test01();
    }
    public static void test01(){
        File file = new File("D:\\有道云笔记Beta版-1.3.1.exe");
        File file1 = new File("E:\\有道云笔记Beta版-1.3.1.exe");
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        try {
            long l = System.currentTimeMillis();
            fileInputStream = new FileInputStream(file);
             fileOutputStream = new FileOutputStream(file1);
             byte[] bytes =new byte[1024*1024*50];
             int len;
             while ((len = fileInputStream.read(bytes))!=-1){
                    fileOutputStream.write(bytes,0,len);
             }
            long l1 = System.currentTimeMillis();
            System.out.println("时间为:"+(l1-l));
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            if (fileInputStream!=null){
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream!=null){
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
